package top.ed333.mcplugins.configurableevents.requirement;

import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerEvent;
import org.jetbrains.annotations.NotNull;
import top.ed333.mcplugins.configurableevents.DependenciesResolver;
import top.ed333.mcplugins.configurableevents.PlayerPointsHelper;

public class PlayerPointLessThanReqGroup extends TargetedByPlayerEventReqGroup {
    public PlayerPointLessThanReqGroup(String groupName, int ext) {
        super(groupName, ext);
    }

    @Override
    public String name() {
        return "PlayerPointLessThan";
    }

    @Override
    public boolean checkReq(@NotNull PlayerEvent event) {
        if (!DependenciesResolver.isPlayerPointsInstalled()) return false;

        Player player = event.getPlayer();
        return PlayerPointsHelper.getPoints(player) <= (int) getExt();
    }
}
